package tech.edwardvan.springsecuritydemo.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 前后端分离
 *
 * @author EdwardVan
 */
@RestController
@RequestMapping("/api")
public class ApiController {
    /**
     * 查看会员信息接口
     *
     * @return
     */
    @PreAuthorize("hasAnyAuthority('api:member')")
    @GetMapping("/member")
    public Object member() {
        return "member";
    }

    /**
     * 查看部署信息接口
     */
    @PreAuthorize("hasAnyAuthority('api:deploy')")
    @GetMapping("/deploy")
    public Object deploy() {
        return "deploy";
    }

    @PreAuthorize("isAuthenticated()")
    @GetMapping("/test")
    public Object test() {
        return "test";
    }
}
